'''
Created on Jul 27, 2011

@author: mhamilton
'''

import time

class timer:
    def __init__(self):
        self.timing_flag = False
        self.past_time = 0
        self.splits = []
        
    def start(self):
        if not self.timing_flag:
            self.timing_flag = True
            self.start_time = time.time()

    def stop(self):
        if self.timing_flag:
            self.timing_flag = False
            self.past_time += (time.time() - self.start_time)
        
    def get_time(self):
        if self.timing_flag:
            return self.past_time + (time.time() - self.start_time)
        return self.past_time 

    def split(self):
        t = self.get_time()
        if self.timing_flag:
            self.splits.append(t)
            return t
        return None
        